<!DOCTYPE html>
<html lang="zh">
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<title>Document</title>
		<link href="/static/layui/css/layui.css" rel="stylesheet">
		<script src="http://code.jquery.com/jquery-latest.js"></script>
		<!-- 引入 layui.js -->
		<script src="/static/layui/layui.js"></script>
	</head>
	<body>
		<form class="layui-form layui-form-pane" style="padding: 20px;" action="">
			<div class="layui-form-item">
				<label class="layui-form-label">品牌名称</label>
				<div class="layui-input-block">
					<input type="text" name="brand" autocomplete="off" placeholder="请输入品牌名称" lay-verify="required"
						class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">产品名称</label>
				<div class="layui-input-block">
					<input type="text" name="product_name" autocomplete="off" placeholder="请输入产品名称" lay-verify="required"
						class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">净含量</label>
				<div class="layui-input-block">
					<input type="text" name="net_content" autocomplete="off" placeholder="请输入净含量" lay-verify="required"
						class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">单位</label>
				<div class="layui-input-block">
					<input type="text" name="unit" autocomplete="off" placeholder="请输入单位" lay-verify="required"
						class="layui-input">
				</div>
			</div>
			<div class="layui-form-item" pane>
				<label class="layui-form-label">状态</label>
				<div class="layui-input-block">
					<input type="radio" name="status" value="0" title="禁用">
					<input type="radio" name="status" value="1" title="开启" checked>
				</div>
			</div>
			<div class="layui-form-item">
				<button class="layui-btn layui-btn-fluid" lay-submit lay-filter="demo-add" id="btn">添加</button>
			</div>
		</form>
		<script type="text/javascript">
			layui.use(function() {
				var laydate = layui.laydate;
				var form = layui.form;
				var layer = layui.layer;
				// 渲染
				laydate.render({
					elem: '#ID-laydate-demo'
				});
				form.on('submit(demo-add)', function(data) {
					var field = data.field;
					var index = parent.layer.getFrameIndex(window.name); 
					
					/* layer.alert(JSON.stringify(field), {
					      title: '当前填写的字段值'
					    }); */
					$.ajax({
						url:'{:url("Disposition/productaddData")}',
						type:'post',
						data:field,
						dataType:'json',
						success: function(res){
						    if (res.code == 200){
								layer.msg(res.msg,{time:500},function(){
									/* parent.layui.table.reload('tablea'); */
									window.parent.location.reload();
									parent.layer.close(index);
									
								});
							}else{
								layer.msg(res.msg);
							}
						}
					});
					return false; // 阻止默认 form 跳转
				});
			});
		</script>
	</body>
</html>